'use strict';
app.service('sellLevelService',['$http','$q','utilService',function($http,$q,utilService){

    this.add=function($scope){
        var deferred = $q.defer();
        utilService.api({
            url:$scope.app.domain + 'sell/level/add',
            data:$scope.sellLevel,
            method:'POST'
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;
    };

    this.findById=function($scope){
        var deferred = $q.defer();
        utilService.get({
            url:$scope.app.domain + 'sell/level/find',
            params:{id:$scope.sellLevelId}
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;

    }

    this.update=function($scope){
        var deferred = $q.defer();
        utilService.api({
            url:$scope.app.domain + 'sell/level/update',
            data:$scope.sellLevel,
            method:'PUT'
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;

    }

    this.delete=function($scope){
        var deferred = $q.defer();
        utilService.api({
            url:$scope.app.domain + 'sell/level/del',
            data:{id:$scope.sellLevelId},
            method:'DELETE'
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;

    }

    this.findMax=function($scope){
        var deferred = $q.defer();
        utilService.get({
            url:$scope.app.domain + 'sell/level/max'
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;
    }
}]);